package com.atguigu.srb.core.controller.admin;

import com.atguigu.common.result.R;
import com.atguigu.srb.core.pojo.entity.UserLoginRecord;
import com.atguigu.srb.core.service.UserLoginRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: Bright
 * @Date: 2022-04-17 22:23
 * @Description: com.atguigu.srb.core.controller.admin
 * @version: 1.0
 */
@Slf4j
@RestController
@Api(tags = "会员登录日志管理")
@RequestMapping("/admin/core/userLoginRecord")
public class AdminUserLoginRecordController {
    @Resource
    UserLoginRecordService userLoginRecordService;

    @ApiOperation(value = "查询前五十条登录记录")
    @GetMapping("/listTop50/{userId}")
    public R getRecordTop50(
            @ApiParam(value = "用户id", required = true)
            @PathVariable Long userId) {

        List<UserLoginRecord> userLoginRecords = userLoginRecordService.listTop50(userId);
        return R.ok().message("查询成功").data("list", userLoginRecords);

    }
}
